//格式化商品数据
export class Goods {
    constructor(itemInfo, columns, shopInfo) {
        this.itemInfo = {
            title: itemInfo.title,
            lowNowPrice: itemInfo.lowNowPrice,
            price: itemInfo.price,
            oldPrice: itemInfo.oldPrice,
            discountDesc: itemInfo.discountDesc,
            discountBgColor: itemInfo.discountBgColor,
            columns: columns
        };

        this.shopInfo = {
            name: shopInfo.name,
            shopLogo: shopInfo.shopLogo,
            shopUrl: shopInfo.shopUrl,
            cGoods: shopInfo.cGoods,
            cSells: shopInfo.cSells,
            score: shopInfo.score
        };

        this.services = shopInfo.services;
    }
}
//格式化商品详情图片数据
export class DetailInfo {
    constructor(detailInfo) {
        this.desc = detailInfo.desc;
        this.detailImage = [];
        //将所有的服装图片归到一个对象里面
        for (const detailInfoElement of detailInfo.detailImage) {
            if (detailInfoElement.list !== undefined) {
                this.detailImage.push(...detailInfoElement.list)
            }
        }
    }
}
//格式化详情参数数据
export class DetailParamsInfo {
    constructor(detailParams) {
        this.productInfo = detailParams.info.set;
        this.sizeInfo = detailParams.rule.tables[0];
    }

}
//格式化商品评论信息
export class GoodsComment {
    constructor(goodsComment) {
        this.headPhoto = goodsComment.user.avatar;
        this.userName = goodsComment.user.uname;
        this.content = goodsComment.content;
        this.createTime = goodsComment.created;
        this.styleInfo = goodsComment.style

        if (goodsComment.images !== undefined) {
            this.images = goodsComment.images
        }
    }
}
//格式化商品推荐数据
export function transformList(goodRecommends) {
    let list = [];
    for (const goodRecommend of goodRecommends) {
            let listItem = {
                show: {
                    img: goodRecommend.image
                },
                title: goodRecommend.title,
                price: goodRecommend.price,
                cfav: goodRecommend.cfav,
                iid: goodRecommend.shop_id
            }
            list.push(listItem)
        }
    return list
}